package adapter.objectadapter;

/**
 * @author : DuJiabao
 * @Date : 2021/3/3 9:37
 * @Project : design-pattern
 * @File : null.java
 * @Desc :
 */
public class VoltageAdapter implements Voltage5V {
  private Voltage220V voltage220V;

  public VoltageAdapter(Voltage220V voltage220V) {
    this.voltage220V = voltage220V;
  }
  public void setVoltage220V(Voltage220V voltage220V) {
    this.voltage220V = voltage220V;
  }

  @Override
  public int output5V() {
    int vol = voltage220V.output220V();
    int output = vol / 44;
    if (output != 5) throw new RuntimeException("输入电压不符合");
    return output;
  }
}
